package demo1;

class Animal{
     int tmp;

    public Animal(int tmp) {
        this.tmp = tmp;
        fun();
    }
    public void fun(){
        System.out.println("父类的！");
    }
}
class Dog extends Animal{
    public Dog(int tmp){
        super(tmp);
    }

    @Override
    public void fun(){
        System.out.println("子类的！"+super.tmp);
    }
}
class Bird extends Animal{

    public Bird(int tmp){
        super(tmp);
    }
    public void fly(){
        System.out.println("飞");
    }
}
public class Test {
    public static void main(String[] args) {
        Animal animal=new Bird(2);
        if(animal instanceof Bird){
            Bird bird=(Bird)animal;
            bird.fly();
        }
        Dog dog=new Dog(2);

    }
}
